import java.util.Scanner;
import java.lang.String;
public class Complex{
    double RealPart;
    double ImagePart;
    public Complex(double R, double I) {
        this.RealPart = R;
        this.ImagePart = I;
    }

    public static double getRealPart(double RealPart) {
        return RealPart;
    }
    public  static double getImagePart(double ImagePart) {
        return ImagePart;
    }

    public boolean equals(Object obj) {
        if(this==obj){
            return true;
        }
        if(!(obj instanceof Complex)) {
            return false;
        }
        Complex complex=(Complex)obj;
        if(complex.RealPart!=((Complex)obj).RealPart){
            return false;
        }
        if(complex.ImagePart!=((Complex)obj).ImagePart){
            return false;
        }
        return true;
    }
    public String toString() {
        String string="";
        if(ImagePart>0)
            string=RealPart+"+"+ImagePart+"i";
        if(ImagePart==0)
            string=RealPart+"";
        if(ImagePart<0)
            string=RealPart+ImagePart+"i";
        return string;
    }
     Complex ComplexAdd(Complex a) {
        double RealPart2=RealPart+ a.RealPart;
        double ImagePart2=ImagePart + a.ImagePart;
        return new Complex(RealPart2,ImagePart2);
    }
     Complex ComplexSub(Complex a) {
        double RealPart2=RealPart - a.RealPart;
        double ImagePart2=ImagePart - a.ImagePart;
        return new Complex(RealPart2,ImagePart2);
    }
    Complex ComplexMulti(Complex a) {
        double RealPart2= RealPart* a.RealPart- ImagePart * a.ImagePart;
        double ImagePart2=ImagePart * a.ImagePart+ImagePart * a.RealPart;
        return new Complex(RealPart2,ImagePart2);
    }
    Complex ComplexDiv(Complex a) {
        double RealPart2= (RealPart * a.ImagePart+ ImagePart * a.RealPart)/(a.ImagePart * a.ImagePart + a.RealPart * a.RealPart);
        double ImagePart2=(ImagePart * a.ImagePart + RealPart * a.RealPart)/(a.ImagePart * a.ImagePart + a.RealPart * a.RealPart);
        return new Complex(RealPart2,ImagePart2);

    }

}
